# 1、导包
import requests
# 2、组织数据
# 2。1url
class Login():
    def __init__(self):
        self.login_url = "http://ihrm-test.itheima.net/api/sys/login"
        self.user_info_url = "http://ihrm-test.itheima.net/api/sys/profile"
        # 2.3 请求头
        self.header = {"Content-Type":"application/json"}

    def login(self):
        # 3、 发送请求
        self.data = {
            "mobile": "13800000002",
            "password": "123456"
        }
        response = requests.post(url=self.login_url,json=self.data,headers = self.header)
        # 4、查看结果
        # print(response.json().get("data"))
        self.header["Authorization"] = "Bearer "+response.json().get("data")
        print(response.json())

    def user_info(self):
        response = requests.post(url=self.user_info_url, headers=self.header)
        print(response.json())

    def login2(self):
    # 3、 发送请求
        self.data = {
            "mobile": "1380000000",
            "password": "123456"
        }
        response = requests.post(url=self.login_url,json=self.data,headers = self.header)
        # 4、查看结果
        print(response.json())


l = Login()
l.login()
l.user_info()
l.login2()